#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    int mySqrt(int x)
    {
        int left = 1, right = x;
        while (left < right)
        {
            long long mid = left + (right - left + 1) / 2;
            if (mid * mid <= x) left = mid;
            else right = mid - 1;
        }
        return right;
    }
};

void Test01()
{
    Solution s;
    cout << s.mySqrt(8);
}

int main()
{
	Test01();
	return 0;
}